<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimum-scale=1.0">
    <title>漠河智慧社区</title>
    <link href="Content/wechat/css/reset.css" rel="stylesheet" type="text/css">
    <!--签到-->
    <link href="Content/wechat/css/tongChengJiaoYou_faBu.css" rel="stylesheet" type="text/css">

    <!--banner-->
    <link href="Content/wechat/css/amazeui.min.css" rel="stylesheet" type="text/css">
    <script src="Content/wechat/js/jquery.min.js"></script>
    <!--字体缩放-->
    <script src="Content/wechat/js/ziti.js"></script>
    <!--end 字体缩放-->
    <!--上传图片js-->
    <script src="Content/wechat/js/svg.js"></script>

    <script src="Content/wechat/js/jquery.validate.js"></script>
    <!--end 上传图片js-->
</head>
<body>
<!--<header class="clearfix">-->
<!--    <h2>评论</h2><button class="quxiao_btn">取消</button>-->
<!--</header>-->
<div class="biaoDan">
    <form name="form1" id="form1" action="" method="post" novalidate>
        <input type="hidden" name="id" value="${id}"/>
        <textarea class="textarea" name="content" placeholder="请输入留言"></textarea>
    </form>
</div>
<div class="button_shangChuan" id="btnAdd">发布</div>
<script>
    var btnAdd = true;
    $().ready(function () {
        $(".button_shangChuan").click(function () {
                if (!btnAdd) {
                    alert("发布中...");
                    return;
                }
                if ($("#form1").valid()) {
                    btnAdd = false;
                    $("#btnAdd").html("发布中...")
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "/wechat/forum/posts_insert",//url
                        data: $('#form1').serialize(),
                        success: function (result) {
                            console.log(result);//打印服务端返回的数据(调试用)
                            if (result.code == 200) {
                                alert(result.info);
                                location.reload();
                                // /wechat/forum/fornum_info?id=120a07aa472143abbb99b4efbe37134d
                            } else {
                                alert("请稍后再试");
                                btnAdd = true;
                                $("#btnAdd").html("发布");
                            }
                        },
                        error: function () {
                            alert("异常！");
                            btnAdd = true;
                            $("#btnAdd").html("发布");
                        }
                    });
                }
            }
        );
        $("#form1").validate({
            rules: {

                content: {
                    required: true,
                    minlength: 5,
                    maxlength: 500,

                }
            },
            messages: {

                content: {
                    minlength: "(字符不能少于 5 个且不能大于 500个)",
                    maxlength: "(字符不能少于 5 个且不能大于 500个)",
                }
            }
        })

    });

</script>
</body>
